package com.glsc.ngateway.common.base.domain.mysql.gateway.oaflow.xirtrade;

import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

/**
 * 衡泰xir指令同步配置表-人员关联配置（xir人员-oa人员）
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_oa_flow_xir_trade_config_user_related set deleted = UNIX_TIMESTAMP(NOW()), handled = 0 where id=?")
@SQLDeleteAll(sql = "update t_oa_flow_xir_trade_config_user_related set deleted = UNIX_TIMESTAMP(NOW()), handled = 0 where id=?")
@Table(name = "t_oa_flow_xir_trade_config_user_related", indexes = {@Index(name = "UK_XIR_USER", columnList = "xir_user_name, deleted", unique = true)})
public class TOaFlowXirTradeConfigUserRelated extends BaseEntity {

    private static final long serialVersionUID = -3264094474527903316L;

    @NotBlank
    @Column(name = "xir_user_name", columnDefinition = "varchar(32) not null")
    private String xirUserName;

    @NotBlank
    @Column(name = "oa_user_name", columnDefinition = "varchar(32) not null")
    private String oaUserName;

}
